package neo.app.service;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import javax.swing.text.Position;

import neo.core.common.PagingList;
import neo.core.util.MapUtil;

public class EmployeeService extends BaseService {

	//获取所有员工列表
	private static final String SQL_GET_ALL_EMPLOYEE = "select * from ken_employee";
	/**
	 * 获取所有员工列表
	 * @return
	 */
	public PagingList getAllEmployee() {
		return getPagingList(SQL_GET_ALL_EMPLOYEE);
	}
	
	//添加员工
	private static final String SQL_INSERT_EMPLOYEE = "insert into ken_employee values(employee_id,?,?,?,?,?,?,?,?,?,?)";
	/**
	 * 添加员工
	 */
	public boolean addEmployee(Map map) {
		//1、获取值
		String employee_no = MapUtil.getStringFromMap(map, "employee_no");
		String employee_name = MapUtil.getStringFromMap(map, "employee_name");
		String employee_tel = MapUtil.getStringFromMap(map, "employee_tel");
		String employee_home_tel = MapUtil.getStringFromMap(map, "employee_home_tel");
		String employee_email = MapUtil.getStringFromMap(map, "employee_email");
		String employee_birthdate = MapUtil.getStringFromMap(map, "employee_birthdate");
		String employee_card_id = MapUtil.getStringFromMap(map, "employee_card_id");
		String employee_address = MapUtil.getStringFromMap(map, "employee_address");
		String employee_workdate = MapUtil.getStringFromMap(map, "employee_workdate");
		String empoyee_remark = MapUtil.getStringFromMap(map, "empoyee_remark");
		
		//2、检查数据有效性
		//3、sql语句
		//4、执行sql
		if(jt.update(SQL_INSERT_EMPLOYEE,new Object[]{employee_no, employee_tel, employee_home_tel, employee_email, employee_birthdate, employee_card_id, employee_address, employee_workdate, empoyee_remark, employee_name }) > 0){
			return true;
		}
		return false;
	}
	
	
	
}
